
package gui;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author JtR
 */
public class ServerPrinter implements Runnable {
    private Process server;
    private boolean running = true;
    
    public ServerPrinter(Process server) {
        this.server = server;
    }
    
    public void stopRunning() {
        running = false;
    }

    @Override
    public void run() {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(server.getInputStream()));
            String line = null;
            
            while(running) {
                line = reader.readLine();
                if(line != null) {
                    System.err.println("*Server*: " + line);
                    System.out.print("");
                }
            }
            reader.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
